<
/**
 * Created by PhpStorm.
 * User: qq
 * Date: 2016/10/10
 * Time: 22:12
 */

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>打印金字塔</title>
    <style>
        .box{background-color:#ff0000;margin:3px;padding:2px;font-size:24px;font-weight:bold;color:#FFF;}
        .out{border:solid 3px #000;float:left;overflow:hidden;}

    </style>
</head>
<body>
<div class="out">
    <div class="box"></body></html>
<?php

$line=1;
while($line<=5) {
    $empty_pos = $star_pos = 1;
    $empty = 5 - $line;
    $star = 2 * $line - 1;
    while ($empty_pos <= $empty) {
        echo '&nbsp;';
        ++$empty_pos;
    }
    while ($star_pos <= $star) {
        echo '*';
        ++$star_pos;
    }
    echo '<br>';
    ++$line;
}

